import 'package:flutter_getx/app/data/db/dao/group_dao.dart';
import 'package:flutter_getx/app/data/db/dao/group_member_dao.dart';
import 'package:flutter_getx/app/data/db/dao/message_dao.dart';
import 'package:flutter_getx/app/data/db/dao/user_dao.dart';
import 'package:flutter_getx/app/data/db/dao/user_friend_dao.dart';
import 'package:get/get.dart';

import '../data/db/database.dart';

class DBService extends GetxService {
  late AppDatabase database;

  UserDao get userDao => database.userDao;

  UserFriendDao get userFriendDao => database.userFriendDao;

  GroupDao get groupDao => database.groupDao;

  GroupMemberDao get groupMemberDao => database.groupMemberDao;

  MessageDao get messageDao => database.messageDao;

  Future<DBService> init() async {
    database =
        await $FloorAppDatabase.databaseBuilder('app_database.db').build();
    return this;
  }

  @override
  Future<void> onInit() async {
    super.onInit();
  }

  @override
  void onClose() {
    super.onClose();
  }
}
